package cn.edu.scau.cmi.zhangjinchuan.singleton;

import java.util.ArrayList;


public class Marshal {
	
	private String name;
	private static final int numOfMarshals = 10;
	private static Marshal marshal;
	private static ArrayList<Marshal> marshals = new ArrayList<Marshal>(numOfMarshals);
	private Marshal(String name) {
		this.name = name;
	}
	
	public static Marshal getInstance(String name) {
		if(marshals.size()<10) {
			marshal = new Marshal(name);
			marshals.add(marshal);
		}
		
		return marshals.get(marshals.size()-1);
	}
	public String toString() {
		return "Marshal"+name+"@" +Integer.toHexString(hashCode());
	}
}
